/**
 * @author        Nicolas Bottarini <nicolasbottarini@gmail.com>, 404 <http://www.proyecto404.com>
 * @version       $Rev: 3 $
 * @lastrevision  $Date: 2011-09-12 16:45:37 +0000 (Mon, 12 Sep 2011) $	 
 */
package com.proyecto404.core.collections {
	import com.proyecto404.core.BaseObject;
	
	public class KeyValuePair extends BaseObject {
		private var _key:String;
		private var _value:*;
		
		public function KeyValuePair(key:String, value:*) {
			_key = key;
			_value = value;
		}
		
		public function get key():String {
			return _key;
		}

		public function set key(value:String):void {
			_key = value;
		}

		public function get value():* {
			return _value;
		}

		public function set value(value:*):void {
			_value = value;
		}
		
		public function implode(separator:String = ","):String {
			return key + separator + value;
		}
		
		public override function toString():String {
			return "KeyValue{" + valueToString(key) + "," + valueToString(value) + "}";
		}
		
		public override function equals(value:*):Boolean {
			if (!(value is KeyValuePair)) { return false; }
			var pair:KeyValuePair = value as KeyValuePair;
			return areEquals(key, pair.key) && areEquals(value, pair.value);
		}
	}
}